package com.eastdigit.org.model;

import com.eastdigit.system.model.Entity;
import com.eastdigit.system.model.IDepartment;
import net.sf.json.JSONObject;

import java.io.Serializable;

public class Department extends Entity implements IDepartment, Serializable {
    private String id;

    private String parentId;

    private String code;

    private String name;

    private String shortName;

    private String fullName;

    private String type;

    private String innerId;

    private static final long serialVersionUID = 1L;

    @Override
    public String getDeptId() {
        return id;
    }

    @Override
    public String getDeptName() {
        return name;
    }

    @Override
    public String getParentDeptId() {
        return parentId;
    }

    @Override
    public JSONObject toJSONObject() {
        JSONObject j = new JSONObject();
        j.put("deptId", id);
        j.put("parentDeptId", parentId);
        j.put("deptCode", code);
        j.put("deptName", name);
        j.put("shortName", shortName);
        j.put("fullName", fullName);
        j.put("deptType", type);
        j.put("deptInnerId", innerId);
        j.put("remark", remark);
        return j;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getInnerId() {
        return innerId;
    }

    public void setInnerId(String innerId) {
        this.innerId = innerId;
    }

    /**
     * 所传部门是否为当前部门下的父亲部门
     * */
    // public boolean isParent(String parentDeptId) {
    // boolean isParent = false;
    // if (!StringUtil.isNull(this.innerId)) {
    // String[] innerIds = this.innerId.split("/");
    // if (innerIds.length > 1 ) {
    // for (int i = 0; i < innerIds.length ; i++) {
    // if (innerIds[i].equals(parentDeptId)) {
    // isParent = true;
    // break;
    // }
    // }
    // }
    // }
    // return isParent;
    // }
}
